\RequirePackage[intlimits]{amsmath}
\RequirePackage{amssymb}
\RequirePackage[mathscr]{eucal}

% подправляем расстояния в дробях
\setbox0=\hbox{$\fontdimen8\textfont2=1.3ex\fontdimen11\textfont2=1.7ex$}
% \fontdimen8 --- под числителем, \fontdimen11 --- над знаменателем

% Ссылки в скобках на уравнения
%\def\eqref#1{{\let\after@math=\relax $(\protect\ref{#1})$}}

% ТЕОРЕМЫ И Т.П.
\def\theorem#1{\smallbreak\vskip 1ex plus.2ex minus.1ex\noindent{\fontSubsection #1.}\hskip.5em\bgroup\it}
\def\endtheorem{\egroup\vskip 1ex plus.2ex minus.1ex\nobreak}
% ДОКАЗАТЕЛЬСТВО: если текст после начинается с маленькой буквы, то двоеточие
% после слова "Доказательство" не ставится
\def\evid#1{\noindent\so{Доказательство}\let\tmpa=#1\let\tmpb=:%
    \if\tmpa\tmpb\kern.7ex:\hskip2ex plus1ex minus1ex\else\hskip2ex plus1ex minus1ex#1\fi}
\def\endevid{\nobreak\kern1.5mm\sq}

\abovedisplayskip=5pt plus3pt minus1pt%
\abovedisplayshortskip=3pt plus3pt%
\belowdisplayskip=5pt plus3pt minus1pt%
\belowdisplayshortskip=3pt plus3pt minus1pt%
\mathsurround=0.4ex % пробелы вокруг формул в тексте
% определение токена пробела
{\def\\{\global\let\spacetoken= } \\ }%
% подавление пробелов перед знаками препинания
% если сразу за формулой следует символ (кроме закрывающей скобки), то матем. керн убивается
% если пробел и тире, то керн убивается и тире сцепляется с формулой
\def\aftermath#1${#1$\futurelet\i@next\i@aftermath}
\def\i@aftermath{\ifx\i@next\spacetoken\let\i@next=\z@aftermath\else\ifx\i@next~\let\i@next=\z@aftermath\else%
    \ifx\i@next)\else\kern-0.8\mathsurround\fi\let\i@next=\relax\fi\fi\i@next}
\def\z@aftermath{\afterassignment\ii@aftermath\let\ii@next= }
\def\ii@aftermath{\futurelet\i@next\iii@aftermath}
\def\iii@aftermath{\ifx\i@next-\kern-1.2\mathsurround\penalty\@M\else\ifx\ii@next~\penalty\@M\fi\fi\spacetoken}
\everymath{\aftermath} \everydisplay{\let\aftermath=\relax}
\def\noaftermath{\let\aftermath=\relax}

\thinmuskip=3mu % тонкий пробел в матмоде
\medmuskip=4mu plus 2mu minus 4mu % средний пробел в матмоде
\thickmuskip=5mu plus 5mu % толстый пробел в матмоде
\edef\mtxt#1{\quad\hbox{#1}\quad} % текст в формулах с пробелами вокруг

\def\norm#1{\left|\kern-1.5pt\left|{#1}\right|\kern-1.5pt\right|}

% Дроби с большой косухой в строке
\def\lfrac#1#2{\setbox0=\hbox{$x$}\lower.3%
    \ht0\hbox{\raise.5\ht0\hbox{$#1$\kern-\mathsurround}%
    \kern-.3\ht0\big/\kern-.3\ht0\lower.5\ht0\hbox{\kern-\mathsurround$#2$}}}
\def\lpd#1#2{\lfrac{\partial#1}{\partial#2}}

%\def\dfrac#1#2{\displaystyle{#1\over #2}}
%\def\pd#1#2{\dfrac{\partial#1}{\partial#2}}
%\def\pdd#1#2{\dfrac{\partial^2#1}{\partial#2^2}}
\def\pd#1#2{\mathchoice{\dfrac{\partial#1}{\partial#2}}{\partial_{#2}{#1}}
    {\partial_{#2}{#1}}{\partial_{#2}{#1}}}
\def\pdd#1#2#3{\mathchoice{\dfrac{\partial^2\mskip-.5\thinmuskip{#1}}
    {\ifx#2#3\partial#2^2\else
    \partial#2\partial#3\fi}}{\ifx#2#3\partial^2_{#2}{#1}\else
    \partial_{#2}\partial_{#3}{#1}\fi}{\ifx#2#3\partial^2_{#2}{#1}\else
    \partial_{#2}\partial_{#3}{#1}\fi}{\ifx#2#3\partial^2_{#2}{#1}\else
    \partial_{#2}\partial_{#3}{#1}\fi}}
\def\od#1#2{\dfrac{d#1}{d#2}}
\def\odd#1#2{\dfrac{d^2#1}{d#2^2}}
\def\iint{\mathop{\int\kern-7pt\int}}
\def\iiint{\mathop{\int\kern-0.5em\int\kern-0.5em\int}\nolimits}
\def\grad{\mathop{{\rm grad}}\nolimits}
\def\divi{\mathop{{\rm div}}\nolimits}
\let\bindiv=\div
\def\rot{\mathop{{\rm rot}}\nolimits}
\def\sh{\mathop{{\rm sh}}\nolimits}
\def\ch{\mathop{{\rm ch}}\nolimits}
\def\sin{\mathop{{\rm sin}}\nolimits}
\def\cos{\mathop{{\rm cos}}\nolimits}
\def\tg{\mathop{{\rm tg}}\nolimits}
\def\ctg{\mathop{{\rm ctg}}\nolimits}
\def\arctg{\mathop{{\rm arctg}}\nolimits}
\def\arcctg{\mathop{{\rm arcctg}}\nolimits}
\def\ln{\mathop{{\rm ln}}\nolimits}
\def\lg{\mathop{{\rm lg}}\nolimits}
\def\const{{\rm const}}
\def\idem{\mathop{{\rm idem}}\nolimits}
\def\mmin{\mathop{{\rm min}}\nolimits}
\def\mmax{\mathop{{\rm max}}\nolimits}
\def\sign{\mathop{{\rm sign}}}
\def\rank{\mathop{{\rm rank}}}
\def\ker{\mathop{{\rm ker}}\nolimits}
\def\deg{\mathop{{\rm deg}}}
\def\mod{\mathop{{\rm mod}}\nolimits}
\def\res{\mathop{{\rm res}}}
\def\erf{\mathop{{\rm erf}}\nolimits}
\def\erfc{\mathop{{\rm erfc}}\nolimits}
\def\Re{\mathop{\mathfrak{R}}\nolimits}
\def\Im{\mathop{\mathfrak{I}}\nolimits}
\def\R{\mathbb{R}}
\def\Q{\mathbb{Q}}
\def\C{\mathbb{C}}
\def\N{\mathbb{N}}
\def\Z{\mathbb{Z}}

\def\eqdef{\mathrel{\stackrel{\rm def}{=}}}
% def по Малоземову
\def\leftdef{\setbox0=\hbox{=}\mathrel{\kern1pt\raise.3pt\hbox{:}\copy0\kern-.75\wd0\copy0\kern1pt}}
\def\rightdef{\setbox0=\hbox{=}\mathrel{\kern1pt\copy0\kern-.75\wd0\copy0\raise.3pt\hbox{:}\kern1pt}}
% сравнить с
\def\leftdef{\setbox0=\hbox{$=$}\mathrel{\kern1pt\raise.25pt\hbox{:}\copy0\kern-.75\wd0\copy0\kern1pt}}
\def\rightdef{\setbox0=\hbox{$=$}\mathrel{\kern1pt\copy0\kern-.75\wd0\copy0\raise.25pt\hbox{:}\kern1pt}}
\def\hat#1{\widehat{#1}}
\def\tilde#1{\widetilde#1}
%\let\@dot=\dot
%\def\dot#1{\@dot{\vbox spread10pt{\hbox{$#1$}}}}

\let\emptyset=\varnothing
\def\epsilon{\varepsilon}
\def\phi{\varphi}
\def\Phi{\varPhi}
\def\Psi{\varPsi}
\def\theta{\vartheta}
\def\Theta{\varTheta}
\def\varrho{\rho}
\def\varsigma{\sigma}

\let\bs=\boldsymbol
\def\vec#1{\noaftermath\boldsymbol{#1}}

% переносы во внутритекстовых формулах
\begingroup
\catcode`\+\active\gdef+{\mathchar8235\nobreak\discretionary{}{\usefont{OT1}{cmr}{m}{n}\char43}{}}
\catcode`\-\active\gdef-{\mathchar8704\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char0}{}}
\catcode`\=\active\gdef={\mathchar12349\nobreak\discretionary{}{\usefont{OT1}{cmr}{m}{n}\char61}{}}
\catcode`\<\active\gdef<{\mathchar12604\nobreak\discretionary{}{\usefont{OML}{cmr}{m}{n}\char"3C}{}}
\catcode`\>\active\gdef>{\mathchar12606\nobreak\discretionary{}{\usefont{OML}{cmr}{m}{n}\char"3E}{}}
\endgroup
\everymath=\expandafter{\the\everymath \mathcode`\==32768 \mathcode`\+=32768
   \mathcode`\-=32768 \mathcode`\<=32768 \mathcode`\>=32768 \relax}%

%Дополнения
\def\cdot{\mathchar8705\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char1}{}}
\def\times{\mathchar8706\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char2}{}}
\def\equiv{\mathrel{\mathchar8721\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char17}{}}}
\def\subseteq{\mathrel{\mathchar8722\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char18}{}}}
\def\supseteq{\mathrel{\mathchar8723\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char19}{}}}
\def\leq{\mathrel{\leqslant\nobreak\discretionary{}{\usefont{U}{msa}{m}{n}\char"36}{}}}
\def\geq{\mathrel{\geqslant\nobreak\discretionary{}{\usefont{U}{msa}{m}{n}\char"3E}{}}}
\def\sim{\mathrel{\mathchar8728\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char24}{}}}
\def\approx{\mathrel{\mathchar8729\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char25}{}}}
\def\subset{\mathrel{\mathchar8730\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char26}{}}}
\def\supset{\mathrel{\mathchar8731\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char27}{}}}
\def\ll{\mathrel{\mathchar8732\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char28}{}}}
\def\gg{\mathrel{\mathchar8733\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char29}{}}}
\def\pm{\mathrel{\mathchar8710\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char6}{}}}
\def\mp{\mathrel{\mathchar8711\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char7}{}}}
\def\in{\mathrel{\mathchar8754\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char50}{}}}
\def\ni{\mathrel{\mathchar8755\nobreak\discretionary{}{\usefont{OMS}{cmsy}{m}{n}\char51}{}}}
\def\neq{\mathrel{\not=\nobreak\discretionary{}{{\usefont{OMS}{cmsy}{m}{n}\char54}=}{}}}
\let\eq\equiv
\let\le=\leq
\let\ge=\geq
\let\ne=\neq
\def\notin{\mathrel{\in\kern-3mm/}}



% интегралы в смысле главного значения
\def\Xint#1{\mathchoice
{\XXint\displaystyle\textstyle{#1}}%
{\XXint\textstyle\scriptstyle{#1}}%
{\XXint\scriptstyle\scriptscriptstyle{#1}}%
{\XXint\scriptscriptstyle\scriptscriptstyle{#1}}%
\!\int}
\def\XXint#1#2#3{\noaftermath{\setbox0=\hbox{$#1{#2#3}{\int}$}
\vcenter{\hbox{$#2#3$}}\kern-.5\wd0}}
\def\ddashint{\Xint=}
\def\dashint{\Xint-}